import { post, get } from '@/utils/request/index';
import ApiUrl from '@/api/url';
import Cookies from 'js-cookie';

/**
 * 获取用户信息
 * @param params
 */
export const getUser = async () => {
  // const res = (await post(ApiUrl.getUser, {})) as any;
  const res:any = {
    data: {
      code: 2000,
      data: {
        userId: 10728,
        userEnglishName: 'vickyxiang',
        userChineseName: '向燕林',
        userFullName: 'vickyxiang(向燕林)',
        userDeptName: '财经IT管理部',
        userDeptNameEn: null,
      },
    },
  };
  if (res.data.code == 2000) {
    Cookies.set('User', res.data.data, { expires: 1 });
    return res.data.data;
  } else {
    return [];
  }
};

/**
 * 获取用户菜单
 * @param params
 */
export const getUserMenus = async () => {
  // const res: any = ((await post(ApiUrl.getMenus, {})) as any).data.data;
  const res: any = [
    {
      id: '3359346',
      name: '银企对账管理',
      code: 'ETMS_RECONCILIATION',
      type: 'MENU',
      path: '/reconciliation',
      permission: 'ETMS_RECONCILIATION',
      children: [
        {
          name: '银企对账管理',
          type: 'MENU',
          path: '',
          children: [
            {
              name: 'vxe框选',
              path: '/reconciliation/#/range',
              children: [],
            },
            {
              name: '任务管理',
              path: '/reconciliation/#/taskManagement',
              children: [],
            },
          ],
        },
      ],
    },
  ];
  return res;
};

export async function logout(parms: any) {
  const rtn = (await get(ApiUrl.logout, parms)) as any;
  return rtn.data;
}
